<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>企业回收信息编辑</title>
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>static/h-ui.admin/css/style.css" />
<script src="<%=basePath%>lib/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script src="<%=basePath%>lib/layer/2.4/layer.js" type="text/javascript"></script>
</head>
<style type="text/css">

body{
background:#f6f6f6;
}

*{
margin:0;
padding:0;
}

.input-text{
width:302px;
height:36px;
color:#000;
border:1px solid #ddd;
border-radius:3px;
margin-left:30px;
font-size:16px;
padding-left:56px
}

.btn-text{
width:301px;
height:36px;
text-align:center;
border:1px solid #ddd;
border-radius:3px;
margin-left: 144px;
background:#118c60;
color:#fff;
font-size:16px;
opacity:0.85;
}

.btn-text:hover{
border:1px solid #fff;
opacity:1;
cursor:pointer;
}


.re_css{
    width:480px;
    height: 40px;
    margin-top:15px;
    position:relative;
}
.la{
width: 83px;
height: 40px;
line-height: 40px;
padding-left: 30px;
display: inline-block;
text-align: right;
font-size:16px;
}


.reg_css{
width:200;
height:60px;
}
.reg_t{
width:600px;
height:300px;
position: relative;
margin: auto;
top: 10px;
border:1px solid #ddd;
font-size: 19px;
text-align: center;
line-height: 60px;
}

.ci{
position: absolute;
top: 4px;
left: 150px;
font-size: 24px;
background: #f2f2f2;
height: 32px;
width: 32px;
text-align: center;
margin-top: 2px;
line-height: 34px;
}

.layercss{
position:fixed;
z-index:19910103;
top:50%;
left:50%;
width:80px;
height:30px;
background:#000;
opacity:0.6;
color:#fff;
line-height:30px;
text-align:center;
}
</style>
<body>
<div class="reg_t">
<input id="bid" type="hidden" value="${bid.bid }">

<div class="re_css"><lable class="la">商品名称：</lable><input id="bidname" <c:if test="${bid.status==1}">disabled="disabled"</c:if>  type="text" class="input-text" value="${bid.brandname}" ck="ck"/></div>
<div class="re_css"><lable class="la">截止时间：</lable><input id="time1" <c:if test="${bid.status==1}">disabled="disabled"</c:if> type="date" class="input-text"  value="${bid.delivery_time}" onblur="dateChange()"/>
<input type="hidden" id="delivery_time" value="${bid.delivery_time}"/>
</div>
<div class="re_css"><lable class="la">商品状态： </lable><select class="input-text" id="sta">
<c:if test="${bid.status==0}"><option value="0" <c:if test="${bid.status==0}">selected="selected"</c:if>>未上架</option></c:if>
 <c:if test="${bid.status==0}"><option value="1" <c:if test="${bid.status==1}">selected="selected"</c:if>>竞价中</option></c:if>
 <c:if test="${bid.status==2}"><option value="2" <c:if test="${bid.status==2}">selected="selected"</c:if>>已结束</option></c:if>
 <c:if test="${bid.status==2}"><option value="3" <c:if test="${bid.status==3}">selected="selected"</c:if>>已完成</option></c:if>
</select>
</div>
<div class="re_css"><lable class="la">商品低价：</lable><input type="text" id="lowprice" class="input-text"  value="${bid.lowprice}" ck="ck"/></div>
<div class="re_css"><input type="button" onclick="infoSave()" class="btn-text" value="保存"/></div>
</div>

<script type="text/javascript">

     function dateChange(){	 
    var time2 =  $("#time1").val();
     if(time2!=null&&time2!=""){
    	 $("#delivery_time").val(time2);
       }
     } 
	function infoSave(){
		var re =/^[1-9]\d*$/;
		//定义一个全局的参数数组
		//判断需要修改的数据的输入框的数量
		var bid =$("#bid").val();
		var bidname =$("#bidname").val();
		var delivery_time =$("#delivery_time").val();
		var status =$("#sta").val();
		var lowprice =parseInt($("#lowprice").val());
	      
		console.log(bid);
		console.log(bidname);
		console.log(delivery_time);
		console.log(status);
		console.log(lowprice);
		
		var f=true;
		if(!re.test(lowprice)){//金额的判断
			alert("请输入一个正确的金额"+lowprice);
			return;
		 }
		
		
		//对所有的输入框做非空验证
		$('[ck="ck"]').each(function(){
			if($(this).val()==null||$(this).val().trim()==""){
				f =false;
				return false;
			}
		}); 
		
	     if(f){
	         $.ajax({
					url:"saveBidEdit",
					type:"post",
					data:{
						bid:bid,
						bidname:bidname,
						delivery_time:delivery_time,
						status:status,
						lowprice:lowprice
						},
				    dataType:"json",
				    success:function(rs){
			     	if(rs.flag){
				  $("body").append('<div class="layercss">修改成功</div>');
				     $(".layercss").fadeOut(1500);
				    setTimeout(function(){var index = parent.layer.getFrameIndex(window.name);
				          parent.layer.close(index);
				          },1500);
				    	}
				    }  
				});		
	    	
		}else{
			 alert("所有的输入框都为必填项");
		}	
	}
</script>
</body>
</html>